var Page = function(){
    this.init();
};
Page.prototype = {
    params: {
        passport: '',
        payId:''
    },
    init: function(){
        this.initParams();
        this.initEvent();
    },
    initParams: function(){
        this.params.passport = Pub.getCookie('_PASSPORT');
        this.params.payId = Pub.getSession('payId');
    },
    getData: function(){
        var _this = this;
        var paramsObj = {
            passport: _this.params.passport,
            payId:_this.params.payId
        };
        console.log(paramsObj);
        Api.paytypedetails(paramsObj, function(data){
            console.log(data);

            $('#name').val(data.name);

            $('#note').val(data.describe);

        });
    },
    submit:function(){
        var _this = this;
        $('#submit').click(function(event) {

            var describe=$('#note').val();

            var paramsObj = {
                passport: _this.params.passport,
                payId:_this.params.payId,
                describe:describe,
            };
            console.log(paramsObj);
            Api.paytypemodify(paramsObj, function(data){
                console.log(data);
                layui.use('layer', function(){
                    layer.msg('编辑成功', {icon: 6});
                    setTimeout(function(){
                        window.location.href = Pub.getHtmlUrl('./payment-set.html');
                    },1500)
                });
            });

        });
    },
    otherEvent:function(){
        var _this = this;
        $('.goods-checkbox input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        })

    },
    initEvent: function(){
        var _this = this;
         _this.getData();
        _this.otherEvent();
        _this.submit();

    }
};
var page = new Page();